package com.crane.app.web.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.crane.common.core.dto.SingleResponse;
import com.crane.oss.app.bean.req.AppAddTaskReq;
import com.crane.oss.app.bean.req.AppCommitCommentReq;
import com.crane.oss.app.bean.req.AppDelCommentReq;
import com.crane.oss.app.bean.req.AppQueryTaskRopeDayDetailReq;
import com.crane.oss.app.bean.resp.AppTeacherSkipRopeResp;
import com.crane.oss.app.bean.resp.TaskSkipPopeDayDetailResp;
import com.crane.oss.app.bean.resp.TaskTeacherSkipPopeResp;
import com.crane.oss.school.bean.request.task.QueryTaskRopeListReq;
import com.crane.oss.school.service.TaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "AppTeacherSkipRopeController", tags = {"任务-跳绳（老师）"})
@RestController
@RequestMapping("/app/teacher/skipRope")
public class AppTeacherSkipRopeController extends BaseAppController {

    @Resource
    TaskService taskService;


    @ApiOperation(value = "老师发布任务", notes = "老师发布任务")
    @ApiImplicitParam(name = "request", value = "请求对象", required = true, dataType = "AppAddTaskReq")
    @PostMapping("/addTask")
    public SingleResponse<Boolean> addTask(@RequestBody AppAddTaskReq request) {
        request.setOpUserId(getUserId());
        return SingleResponse.of(taskService.addTask(request));
    }

    @ApiOperation(value = "老师跳绳任务列表", notes = "老师跳绳任务列表")
    @ApiImplicitParam(name = "request", value = "请求对象", required = true, dataType = "QueryTaskRopeListReq")
    @PostMapping("/queryTaskRopeList")
    public SingleResponse<IPage<AppTeacherSkipRopeResp>> queryTaskRopeList(@RequestBody QueryTaskRopeListReq request) {
        request.setTeacherId(getUserId());
        return SingleResponse.of(taskService.queryTeacherSkipRopeList(request));
    }


    @ApiOperation(value = "查询任务详情", notes = "查询任务详情")
    @ApiImplicitParam(name = "taskId", value = "任务id", paramType = "path", dataType = "Long")
    @GetMapping("/detail/{taskId}")
    public SingleResponse<TaskTeacherSkipPopeResp> queryTeacherSkipRopeDetail(@PathVariable("taskId") Long taskId) {
        return SingleResponse.of(taskService.queryTeacherSkipRopeDetail(taskId, getPartyId()));
    }

    @ApiOperation(value = "查询任务当日打卡详情", notes = "查询任务当日打卡详情")
    @ApiImplicitParam(name = "request", value = "请求对象", required = true, dataType = "AppQueryTaskRopeDayDetailReq")
    @PostMapping("/queryTeacherSkipRopeDayDetail")
    public SingleResponse<TaskSkipPopeDayDetailResp> queryTeacherSkipRopeDayDetail(@RequestBody AppQueryTaskRopeDayDetailReq request) {
        return SingleResponse.of(taskService.queryTeacherSkipRopeDayDetail(request));
    }



    @ApiOperation(value = "删除任务", notes = "删除任务")
    @ApiImplicitParam(name = "taskId", value = "任务id", paramType = "path", dataType = "Long")
    @GetMapping("/del/{taskId}")
    public SingleResponse<Boolean> delTask(@PathVariable("taskId") Long taskId) {
        return SingleResponse.of(taskService.delTask(taskId, getPartyId()));
    }

    @ApiOperation(value = "提交评论", notes = "提交评论")
    @ApiImplicitParam(name = "request", value = "请求对象", required = true, dataType = "AppCommitCommentReq")
    @PostMapping("/commitComment")
    public SingleResponse<Boolean> commitComment(@RequestBody AppCommitCommentReq request) {
        return SingleResponse.of(taskService.commitComment(request));
    }

    @ApiOperation(value = "删除评论", notes = "删除评论")
    @ApiImplicitParam(name = "request", value = "请求对象", required = true, dataType = "AppDelCommentReq")
    @PostMapping("/delComment")
    public SingleResponse<Boolean> delComment(@RequestBody AppDelCommentReq request) {
        return SingleResponse.of(taskService.delComment(request));
    }

}
